Add SQL Server 2025 to integration tests#2435
Conversation
WalkthroughComprehensive addition of SQL Server 2025 support to the integration test matrix, including CI/CD pipeline updates, compatibility level enhancements, version-aware logic for SQL 2025 (major version 17), and updated test coverage across integration and unit tests with new Integration_SQL2025 tags. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2435 +/- ##
=====================================
- Coverage 94% 94% -1%
=====================================
Files 225 225
Lines 10759 10769 +10
=====================================
+ Hits 10139 10142 +3
- Misses 620 627 +7
🚀 New features to boost your workflow:
|
|
We are getting error: This is probably due to breaking changes mentioned in Replication components fail after an upgrade and particular for this error with Logs: Context When using configuration DSC_SqlReplication_AddPublisher_Config
VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' =
SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' =
root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer runnervm72i71 with user sid
S-1-5-21-2352410390-259027302-1052514532-500.
VERBOSE: [runnervm72i71]: LCM: [ Start Set ]
VERBOSE: [runnervm72i71]: LCM: [ Start Resource ] [[SqlReplication]Integration_Test]
VERBOSE: [runnervm72i71]: LCM: [ Start Test ] [[SqlReplication]Integration_Test]
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] Determines if the distribution
is configured in desired state.
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] Get the current state of the
server replication configuration for the instance 'MSSQLSERVER'.
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] Loading module from path
'D:\a\1\s\output\builtModule\SqlServerDsc\17.5.0\Modules\DscResource.Base\2.0.0\DscResource.Base.psm1'.
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] There are currently no
distributor mode set for the instance 'MSSQLSERVER'.
VERBOSE: [runnervm72i71]: LCM: [ End Test ] [[SqlReplication]Integration_Test] in 3.0450 seconds.
VERBOSE: [runnervm72i71]: LCM: [ Start Set ] [[SqlReplication]Integration_Test]
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] The remote distribution will be
configured.
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] Creating the distributor
publisher 'runnervm72i71' on the instance 'runnervm72i71\DSCSQLTEST'.
VERBOSE: [runnervm72i71]: [[SqlReplication]Integration_Test] Installing the remote
distributor 'runnervm72i71\DSCSQLTEST'.
##[error] [-] Should compile and apply the MOF without throwing 5.17s (5.16s|9ms)
##[error] CimException: System.InvalidOperationException: The call to 'Install-RemoteDistributor' failed. ---> System.Management.Automation.MethodInvocationException: Exception calling "InstallDistributor" with "2" argument(s): "An exception occurred while executing a Transact-SQL statement or batch." ---> Microsoft.SqlServer.Management.Common.ExecutionFailureException: An exception occurred while executing a Transact-SQL statement or batch. ---> Microsoft.Data.SqlClient.SqlException: SSL Provider: The certificate chain was issued by an authority that is not trusted.
##[error] Changed database context to 'master'.
##[error] OLE DB provider "MSOLEDBSQL19" for linked server "repl_distributor" returned message "Client unable to establish connection. For solutions related to encryption errors, see [https://go.microsoft.com/fwlink/?linkid=2227882.".](https://go.microsoft.com/fwlink/?linkid=2227882.%22.)
##[error] at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
##[error] at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
##[error] at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
##[error] at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
##[error] at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
##[error] at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
##[error] at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
##[error] at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
##[error] --- End of inner exception stack trace ---
##[error] at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
##[error] at Microsoft.SqlServer.Replication.ReplicationObject.ExecCommand(String commandIn)
##[error] at Microsoft.SqlServer.Replication.ReplicationServer.InstallDistributor(String distributionServerName, String password)
##[error] at CallSite.Target(Closure , CallSite , Object , String , Object )
##[error] --- End of inner exception stack trace ---
##[error] at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
##[error] at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
##[error] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[error] at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
##[error] --- End of inner exception stack trace ---
##[error] at <ScriptBlock>, D:\a\1\s\tests\Integration\Resources\DSC_SqlReplication.Integration.Tests.ps1:175 |
…ng stored procedure
…e for SQL instance connection
762f02f to
c6148bb
Compare
…ce certificate import in New-SQLSelfSignedCertificate
…erverDsc.Common strings
… numeric values to 'Version' prefixed format
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
source/DSCResources/DSC_SqlReplication/DSC_SqlReplication.psm1 (1)
602-665: Escape distributor/password values before embedding in T‑SQL.
Unescaped values can break the statement (e.g., single quotes) or allow injection. Escape or parameterize before composing the query.🛠️ Suggested fix (escape single quotes)
- $clearTextPassword = $AdminLinkCredentials.GetNetworkCredential().Password + $clearTextPassword = $AdminLinkCredentials.GetNetworkCredential().Password + $escapedDistributor = $RemoteDistributor.Replace("'", "''") + $escapedPassword = $clearTextPassword.Replace("'", "''") - $query = "EXECUTE sys.sp_adddistributor `@distributor` = N'$RemoteDistributor', `@password` = N'$clearTextPassword', `@encrypt_distributor_connection` = 'optional', `@trust_distributor_certificate` = 'yes';" + $query = "EXECUTE sys.sp_adddistributor `@distributor` = N'$escapedDistributor', `@password` = N'$escapedPassword', `@encrypt_distributor_connection` = 'optional', `@trust_distributor_certificate` = 'yes';"
🤖 Fix all issues with AI agents
In `@CHANGELOG.md`:
- Around line 15-17: Update the Unreleased → Changed list in CHANGELOG.md to
contain no more than two items by consolidating or removing one of the three
current bullets (referencing the entries for Connect-Sql, Invoke-SqlDscQuery,
and SQL Server 2025); also format the product name "SQL Server 2025" in italics
(i.e., _SQL Server 2025_) so the CHANGELOG uses italicized product/module names
consistently.
In `@tests/Integration/Resources/DSC_SqlReplication.Integration.Tests.ps1`:
- Line 53: The AddPublisher_Config test context must be skipped for SQL Server
2025 due to ODBC/encryption changes; update the Context declaration named
"AddPublisher_Config" to include a -Skip parameter that excludes the
'Integration_SQL2025' tag (e.g., -Skip @('Integration_SQL2025')), following the
same pattern used in DSC_SqlSetup.Integration.Tests.ps1 so the
AddPublisher_Config context will not run for the Integration_SQL2025 tag.
In `@tests/Integration/Resources/DSC_SqlSetup.Integration.Tests.ps1`:
- Around line 258-267: The test Context 'Ensure TLS 1.2 is enabled' is marked
with an unconditional -Skip so the precheck never runs; remove the -Skip (or
make it conditional) on that Context declaration so the assertions using
Test-TlsProtocol (and the client variant Test-TlsProtocol -Client) execute
during Integration_SQL2025 runs; locate the Context block named 'Ensure TLS 1.2
is enabled' and either delete the -Skip token or replace it with a conditional
expression that only skips when appropriate for non-SQL2025 pipelines.
🧹 Nitpick comments (9)
tests/Integration/Resources/DSC_SqlAlwaysOnService.Integration.Tests.ps1 (1)
69-73: Good: Using-Skipswitch is correct Pester v5 syntax.The change from
-Tag 'Skip'to-Skipis appropriate—the-Skipswitch actually skips test execution, whereas-Tag 'Skip'only labels the test without skipping it.However, since this PR adds SQL Server 2025 to integration tests, consider updating the TODO comment to include
Integration_SQL2025in the tag list for when this test is re-enabled.Also, there's a double space before the opening brace on line 73.
📝 Suggested update
<# TODO: This has temporarily been disabled as the test is not passing. - Tags should be changed to @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') + Tags should be changed to @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022', 'Integration_SQL2025') #> -Describe "$($script:dscResourceName)_Integration" -Skip { +Describe "$($script:dscResourceName)_Integration" -Skip {tests/Integration/Commands/Set-SqlDscDatabaseDefault.Integration.Tests.ps1 (1)
116-120: Consider moving database cleanup to AfterAll.The test database removal is currently in an
Itblock, which may not execute if earlier tests fail. Moving this to theAfterAllblock (lines 65-68) ensures cleanup runs reliably regardless of test outcomes.♻️ Suggested refactor
AfterAll { + # Clean up the test database + $null = Remove-SqlDscDatabase -ServerObject $script:serverObject -Name $script:testDatabaseName -Force + # Disconnect from the database engine. Disconnect-SqlDscDatabaseEngine -ServerObject $script:serverObject }Then remove the cleanup Context block (lines 116-120).
tests/Integration/Commands/Get-SqlDscTraceFlag.Integration.Tests.ps1 (1)
39-42: Consider removing unused credential variable.
$script:mockSqlAdminCredentialis defined but never used in any test. TheGet-SqlDscTraceFlagcommand uses WMI/Configuration Manager and doesn't require database credentials.♻️ Suggested cleanup
BeforeAll { $script:mockInstanceName = 'DSCSQLTEST' $script:mockComputerName = Get-ComputerName - $mockSqlAdministratorUserName = 'SqlAdmin' # Using computer name as NetBIOS name throw exception. - $mockSqlAdministratorPassword = ConvertTo-SecureString -String 'P@ssw0rd1' -AsPlainText -Force - - $script:mockSqlAdminCredential = [System.Management.Automation.PSCredential]::new($mockSqlAdministratorUserName, $mockSqlAdministratorPassword) - # Get the service object for testing the ByServiceObject parameter set $script:serviceObject = Get-SqlDscManagedComputerService -ServiceType 'DatabaseEngine' -InstanceName $script:mockInstanceName -ErrorAction 'Stop' }tests/Unit/SqlServerDsc.Common/Public/Connect-Sql.Tests.ps1 (1)
408-414: Consider verifyingEncryptConnectionproperty when using-Encryptswitch.The test validates the connection instance but doesn't assert that
EncryptConnectionis set correctly when the-Encryptparameter is used.💡 Suggested enhancement
It 'Should return the correct service instance' -Skip:($IsLinux -or $IsMacOS) { $databaseEngineServerObject = Connect-SQL -Encrypt -ServerName $mockExpectedDatabaseEngineServer -InstanceName $mockExpectedDatabaseEngineInstance -ErrorAction 'Stop' $databaseEngineServerObject.ConnectionContext.ServerInstance | Should -BeExactly "$mockExpectedDatabaseEngineServer\$mockExpectedDatabaseEngineInstance" + $databaseEngineServerObject.ConnectionContext.EncryptConnection | Should -BeTrue Should -Invoke -CommandName New-Object -Exactly -Times 1 -Scope It ` -ParameterFilter $mockNewObject_MicrosoftDatabaseEngine_ParameterFilter }tests/Integration/Commands/Prerequisites.Integration.Tests.ps1 (1)
272-281: Remove redundant tag from innerItblock.The
-Tag @('Integration_SQL2025')on Line 275 is redundant since the parentContextblock at Line 272 already has this tag. Pester inherits tags from parent blocks.♻️ Suggested fix
Context 'Ensure TLS 1.2 is enabled' -Tag @('Integration_SQL2025') -Skip { # SQL Server 2025 installation can fail when TLS 1.2 is disabled: # https://learn.microsoft.com/en-us/sql/sql-server/sql-server-2025-known-issues?view=sql-server-ver17#sql-server-2025-installation-fails-when-tls-12-is-disabled - It 'Should have TLS 1.2 enabled on the node' -Tag @('Integration_SQL2025') { + It 'Should have TLS 1.2 enabled on the node' { # Test-TlsProtocol returns $true when the protocol is enabled. # Assert for both Server and Client registry keys. (Test-TlsProtocol -Protocol 'Tls12') | Should -BeTrue (Test-TlsProtocol -Protocol 'Tls12' -Client) | Should -BeTrue } }tests/Integration/Resources/DSC_SqlSecureConnection.Integration.Tests.ps1 (1)
67-67: Consider adding a comment explaining why SQL Server 2025 is excluded.The
Integration_SQL2025tag is intentionally commented out, which aligns with the PR comments about SSL/certificate trust errors in SQL Server 2025. Adding an inline comment block above this line would help future maintainers understand the exclusion reason and when it might be safe to re-enable.💡 Suggested improvement
+<# + SQL Server 2025 is excluded due to certificate/SSL trust issues. + See: https://learn.microsoft.com/sql/relational-databases/replication/ + "Adding a remote replication distributor fails" section. + TODO: Re-enable when certificate trust handling is resolved. +#> Describe "$($script:dscResourceName)_Integration" -Tag @('Integration_SQL2016', 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022') { # 'Integration_SQL2025'tests/Integration/Commands/Remove-SqlDscAgentOperator.Integration.Tests.ps1 (1)
43-43: Consider using array syntax for tag consistency.The
Integration_SQL2025tag addition is correct. However, this file uses comma-separated tags without the array wrapper, while other integration tests in this PR use@(...)array syntax. Both are valid, but using array syntax would improve consistency across the codebase.🔧 Suggested change for consistency
-Describe 'Remove-SqlDscAgentOperator' -Tag 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022', 'Integration_SQL2025' { +Describe 'Remove-SqlDscAgentOperator' -Tag @('Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022', 'Integration_SQL2025') {tests/Integration/Commands/Enable-SqlDscAgentOperator.Integration.Tests.ps1 (1)
43-43: Consider using array syntax for consistency.The tag addition is correct. However, this file uses comma-separated values without the
@()array wrapper, while other integration test files in this PR use@('tag1', 'tag2', ...)syntax.🔧 Optional fix for consistency
-Describe 'Enable-SqlDscAgentOperator' -Tag 'Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022', 'Integration_SQL2025' { +Describe 'Enable-SqlDscAgentOperator' -Tag @('Integration_SQL2017', 'Integration_SQL2019', 'Integration_SQL2022', 'Integration_SQL2025') {As per coding guidelines: "For single-line arrays use:
@('one', 'two', 'three')"tests/TestHelpers/CommonTestHelper.psm1 (1)
326-336: Good addition to address SQL Server 2025 certificate trust requirements.This change addresses the SSL certificate chain trust error mentioned in the PR comments for SQL Server 2025 replication tests. Importing the self-signed certificate into
Cert:\LocalMachine\Rootensures the certificate is trusted for SQL Server connections that require encryption.Minor observation: Line 330 uses double backslashes (
Cert:\\LocalMachine\\Root) in the verbose message, which will display literally. This is cosmetic only.🔧 Optional fix for consistent path display
- Write-Verbose -Message ('Imported certificate into Cert:\\LocalMachine\\Root with thumbprint ''{0}''.' -f $certificate.Thumbprint) + Write-Verbose -Message ('Imported certificate into Cert:\LocalMachine\Root with thumbprint ''{0}''.' -f $certificate.Thumbprint)
johlju
left a comment
There was a problem hiding this comment.
@johlju reviewed 153 files and all commit messages, made 1 comment, and resolved 13 discussions.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @johlju).
Pull Request (PR) description
This Pull Request (PR) fixes the following issues
Task list
file CHANGELOG.md. Entry should say what was changed and how that
affects users (if applicable), and reference the issue being resolved
(if applicable).
This change is